<template>
  <h1>报价审核</h1>
  &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;年份： &nbsp;&nbsp;<el-select v-model="yearObj"
                                                                                @change="findTitle(yearObj)"
                                                                                style="width: 100px">
  <el-option v-for="obj in yearList" :label="obj" :value="obj" :key="obj"/>
</el-select>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  &nbsp;&nbsp; 招标书标题：
  <el-select v-model="titleObj" @change="findByItem()" value-key="idNum">
    <el-option v-for="typeObj in titleList" :label="typeObj.title" :value="typeObj" :key="typeObj.idNum"/>
  </el-select>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  &nbsp;&nbsp; 类别： &nbsp;&nbsp;
  <el-select v-model="statusObj" @change="findByItem()">
    <el-option v-for="typeObj in typeList" :label="typeObj.label" :value="typeObj" :key="typeObj"/>
  </el-select>
  <el-button type="primary" style="margin-left: 30px" @click="findByItem()">查询</el-button>
  <div v-if="show1">
    <el-empty description="暂无记录"></el-empty>
  </div>
  <div v-if="show">

    <br><br>
    <el-table :data="tvList.records" style="width: 96%;margin: auto;height: 431px" border stripe>
      <el-table-column fixed prop="idNum" label="招标书编号" width="240px"/>
      <el-table-column fixed prop="tenderIdNum" label="投标书编号" width="240px"/>
      <el-table-column prop="vendor.firm" label="供应商公司" width="180px"/>
      <el-table-column label="状态" width="120px">
        <template #default="scope">
          <el-tag type="info" size="default" v-if="scope.row.status===1">待审核</el-tag>
          <el-tag type="defalut" size="default" v-if="scope.row.status===2">未中标</el-tag>
          <el-tag type="warning" size="default" v-if="scope.row.status===3">已中标</el-tag>
        </template>
      </el-table-column>
      <el-table-column label="投标书详情">
        <template #default="scope">
          <a :href="scope.row.src" target="_blank">
            查看
          </a>
        </template>
      </el-table-column>
      <el-table-column label="操作">
        <template #default=scope>
          <el-button type="success" size="small" @click="updateStatus(scope.row,1)" v-if="scope.row.status===0">采用
          </el-button>
          <el-button type="danger" size="small" @click="updateStatus(scope.row.tenderVendorId,2)"
                     v-if="scope.row.status===0">弃用
          </el-button>
        </template>
      </el-table-column>
    </el-table>
    <br>
    <br>
    <div style="width: 90%;margin: auto">
      <el-pagination v-model:current-page="pageNO" v-model:page-size="pageSize" background
                     :total="tvList.total" @current-change="findByItem()" style="width: 95%">
      </el-pagination>
    </div>

  </div>
</template>

<script>
import axios from "axios";

export default {
  data() {
    return {
      paying: '',
      showImg: false,
      pageSize: 8,
      pageNO: 1,
      titleList: [
        {title: "双十一采购", idNum: "0"},
        {title: "双十二采购", idNum: "1"},
      ],
      yearList: [2001, 2002, 2003, 2004],
      typeList: [
        {label: "所有", value: -1},
        {label: "待审核", value: 1},
        {label: "已中标", value: 3},
        {label: "未中标", value: 2},
      ],
      yearObj: 2001,
      titleObj: {title: "2022年双十一采购", idNum: "7"},
      statusObj: {label: "所有订单", value: -1},

      tvList: {
        records: [
          {
            idNum: '20114521',
            vendor: {name: '华为'},
            tenderIdNum: '45213245',
            status: 0,
            src: 'http://hzx.ezy2.top/%E7%BD%97%E5%B0%91%E8%94%9A%E4%B8%AA%E4%BA%BA%E7%AE%80%E5%8E%86.pdf'
          },
          {
            idNum: '20114521',
            vendor: {name: '联想'},
            tenderIdNum: '45213246',
            status: 1,
            src: 'http://hzx.ezy2.top/%E7%BD%97%E5%B0%91%E8%94%9A%E4%B8%AA%E4%BA%BA%E7%AE%80%E5%8E%86.pdf'
          },
          {
            idNum: '20114521',
            vendor: {name: '小米'},
            tenderIdNum: '45213247',
            status: 2,
            src: 'http://hzx.ezy2.top/%E7%BD%97%E5%B0%91%E8%94%9A%E4%B8%AA%E4%BA%BA%E7%AE%80%E5%8E%86.pdf'
          },
          {
            idNum: '20114521',
            vendor: {name: '华为'},
            tenderIdNum: '45213245',
            status: 0,
            src: 'http://hzx.ezy2.top/%E7%BD%97%E5%B0%91%E8%94%9A%E4%B8%AA%E4%BA%BA%E7%AE%80%E5%8E%86.pdf'
          },
          {
            idNum: '20114521',
            vendor: {name: '联想'},
            tenderIdNum: '45213246',
            status: 1,
            src: 'http://hzx.ezy2.top/%E7%BD%97%E5%B0%91%E8%94%9A%E4%B8%AA%E4%BA%BA%E7%AE%80%E5%8E%86.pdf'
          },
          {
            idNum: '20114521',
            vendor: {name: '小米'},
            tenderIdNum: '45213247',
            status: 2,
            src: 'http://hzx.ezy2.top/%E7%BD%97%E5%B0%91%E8%94%9A%E4%B8%AA%E4%BA%BA%E7%AE%80%E5%8E%86.pdf'
          },
          {
            idNum: '20114521',
            vendor: {name: '华为'},
            tenderIdNum: '45213245',
            status: 0,
            src: 'http://hzx.ezy2.top/%E7%BD%97%E5%B0%91%E8%94%9A%E4%B8%AA%E4%BA%BA%E7%AE%80%E5%8E%86.pdf'
          },
        ],
        total: 20,

      },
      user: {},
      show: true,
      show1: false,
    }
  },
  methods: {
    findYear() {
      axios.get("/project/tender/findAllYear").then(resp => {
        if (resp.data != null) {
          this.yearList = resp.data
          this.yearObj = this.yearList[0]
          this.findTitle(this.yearObj);
        }
      })
    },
    findTitle(time) {
      axios.get("/project/tender/findTitleByYear/" + time).then(resp => {
        if (resp.data != null) {
          this.titleList = resp.data
          this.titleObj = this.titleList[0]
          this.findByItem()
        }
      })
    },
    findByItem() {
      axios.get("/project/tv/findByTId/" + this.titleObj.idNum + "/" + this.statusObj.value + "/" + this.pageNO).then(resp => {
        if (resp.data != null) {
          this.tvList = resp.data
        }
      })
    },
    updateStatus(obj, status) {
      axios.get("/project/tv/updateStatus/" + obj.tenderVendorId + "/" + status + "/" + obj.vendor.firm).then(resp => {
        if (resp.data == "ok") {
          this.findByItem();
        }
      })
    },
  },
  created() {
    this.findYear();
  }
}
</script>

<style scoped>

</style>